package vo {
	import org.davekeen.flextrine.orm.PersistentCollection;
	import org.davekeen.flextrine.orm.FlextrineError;
  	import vo.Appointment;
   	import vo.PhoneNumber;
   	import vo.Doctor;
  
	[Bindable]
	public class PatientEntityBase {
		
		public var isUnserialized__:Boolean;
		
		public var isInitialized__:Boolean = true;
		
		public var isCollectionInitializedMap__:Object = new Object();
		
		[Id]
		public var id:String;
		
		public function get name():String { checkIsInitialized("name"); return _name; }
		public function set name(value:String):void { _name = value; }
		private var _name:String;
		
		public function get address():String { checkIsInitialized("address"); return _address; }
		public function set address(value:String):void { _address = value; }
		private var _address:String;
		
		public function get postcode():String { checkIsInitialized("postcode"); return _postcode; }
		public function set postcode(value:String):void { _postcode = value; }
		private var _postcode:String;
		
		[Association]
		public function get appointments():PersistentCollection { checkIsInitialized("appointments"); return _appointments; }
		public function set appointments(value:PersistentCollection):void { _appointments = value; }
		private var _appointments:PersistentCollection;
		
		[Association]
		public function get phoneNumbers():PersistentCollection { checkIsInitialized("phoneNumbers"); return _phoneNumbers; }
		public function set phoneNumbers(value:PersistentCollection):void { _phoneNumbers = value; }
		private var _phoneNumbers:PersistentCollection;
		
		[Association]
		public function get doctor():Doctor { checkIsInitialized("doctor"); return _doctor; }
		public function set doctor(value:Doctor):void { _doctor = value; }
		private var _doctor:Doctor;
		
		public function PatientEntityBase() {
			appointments = new PersistentCollection();
			phoneNumbers = new PersistentCollection();
		}
		
		public function toString():String {
			return "[Patient id=" + id + "]";
		}
		
		private function checkIsInitialized(property:String):void {
			if (!isInitialized__ && isUnserialized__)
				throw new FlextrineError("Attempt to get property '" + property + "' on unitialized Patient.  Consider using EntityManager::require or eager loading.", FlextrineError.ACCESSED_UNITIALIZED_ENTITY);
		}
		
	}

}
